package com.sl.au.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.sl.au.entity.Option;

@Entity
@Table(name = "sl_au_user")
public class User extends Root {

	@Column
	private String name;
	@Column
	private String sex;
	/**
	 * 职务
	 */
	@Column(name = "sPosition")
	private String position;
	/**
	 * 岗位
	 */
	@ManyToOne
	@JoinColumn(name = "sPost", nullable = true)
	private Option post;
	/**
	 * 人员顺序号
	 */
	@Column(name = "sOrderNum")
	private String orderNum;

	/**
	 * 人员电话
	 */
	@Column(name = "sContactType")
	private String contactType;

	/**
	 * 人员邮箱
	 */
	@Column(name = "sEmail")
	private String email;

	/**
	 * 人员层次
	 */
	@Column(name = "sOrder")
	private String order;
	
	/**
	 * 头像地址
	 */
	@Column(name = "pictureAddress")
	private String pictureAddress;

	@ManyToOne
	@JoinColumn(name = "hierarchy", nullable = true)
	private Hierarchy hierarchy;// 组织层级

	@ManyToOne
	@JoinColumn(name = "grading", nullable = true)
	private Grading grading;// 评分层级
	
	/**
	 * 备注
	 */
	@Column(name = "memo")
	private String memo;

	@JsonBackReference
	@ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
	@JoinTable(name = "sl_wcsi_user_grid", joinColumns = { @JoinColumn(name = "user_id") }, inverseJoinColumns = {
			@JoinColumn(name = "grid_id") })
	private Set<GridAreaInfo> grids=new HashSet<>();
	/** 界面中使用，是否选中 **/
	@Transient
	private Boolean isSelected;

	public Boolean getIsSelected() {
		return isSelected;
	}

	public void setIsSelected(Boolean isSelected) {
		this.isSelected = isSelected;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getPosition() {
		return position;
	}

	public void setPosition(String position) {
		this.position = position;
	}

	public Option getPost() {
		return post;
	}

	public void setPost(Option post) {
		this.post = post;
	}

	public String getOrderNum() {
		return orderNum;
	}

	public void setOrderNum(String orderNum) {
		this.orderNum = orderNum;
	}

	public String getContactType() {
		return contactType;
	}

	public void setContactType(String contactType) {
		this.contactType = contactType;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getOrder() {
		return order;
	}

	public void setOrder(String order) {
		this.order = order;
	}

	public Hierarchy getHierarchy() {
		return hierarchy;
	}

	public void setHierarchy(Hierarchy hierarchy) {
		this.hierarchy = hierarchy;
	}

	public Grading getGrading() {
		return grading;
	}

	public void setGrading(Grading grading) {
		this.grading = grading;
	}

	public Set<GridAreaInfo> getGrids() {
		return grids;
	}

	public void setGrids(Set<GridAreaInfo> grids) {
		this.grids = grids;
	}

	public String getPictureAddress() {
		return pictureAddress;
	}

	public void setPictureAddress(String pictureAddress) {
		this.pictureAddress = pictureAddress;
	}

	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}
	
}
